import React from 'react'
import store from '../../store/store'
import { getMovieAction } from "../../store/actions/movieAction.js";

export default function 我是Movie组件() {
    // 用getState方法,从store中结构出想要的数据
    const { count } = store.getState().count
    const { movieList } = store.getState().movie

    // 点击获取电影数据,在actions里面通过函数封装获取数据
    const getmovieHandle=()=>{
        store.dispatch(getMovieAction())
    }

    return (
        <div>
            <h1>我是Movie组件</h1>
            <p>我收到的Count组件的值是{count}</p>
            <button onClick={getmovieHandle}>获取电影的数据</button>
            <ul>
                {
                    movieList.map(item=>{
                        return <li key={item.tvId}>{item.albumName}</li>
                    })
                }
            </ul>
        </div>
    )
}
